package com.qianfeng.xinyihezi.xinyihezi.adapter.adapter_meng;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.qianfeng.xinyihezi.xinyihezi.R;
import com.qianfeng.xinyihezi.xinyihezi.customview.CircleImageView;
import com.qianfeng.xinyihezi.xinyihezi.model.bean_meng.User;
import com.qianfeng.xinyihezi.xinyihezi.utils.utils_meng.GlideCircleTransform;

import java.util.List;

/**
 * Created by Administrator on 2016/11/14.
 */

public class MyRecycleViewAdapter extends RecyclerView.Adapter {
    private List<User> mList;
    private Context mContext;

    public MyRecycleViewAdapter(List<User> mList, Context mContext) {
        this.mList = mList;
        this.mContext = mContext;
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {
        ImageView mImageView;

        public MyViewHolder(View itemView) {
            super(itemView);
            mImageView = (ImageView) itemView.findViewById(R.id.iv_item_recycle);
        }
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MyViewHolder(View.inflate(mContext, R.layout.item_recycle, null));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (position <= 4) {
            MyViewHolder mHolder = (MyViewHolder) holder;
            Glide.with(mContext).load(mList.get(position).avatar)
                    .transform(new GlideCircleTransform(mContext))
                    .into(mHolder.mImageView);
        }
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }
}
